package dxunderground.chatbot;

import java.io.File;
import java.io.IOException;

import org.jdom.Element;
import org.jdom.JDOMException;

public interface Bot extends Runnable {
	/**
	 * @param request
	 *            The input string to be searched for.
	 * @return a valid element with the response saved in the text location.
	 */
	public Element getResponse(String request);

	/**
	 * Creates and adds a response Element to request
	 * 
	 * @param request
	 * @param response
	 * @return the newly created response Element.
	 */
	public Element addResponse(Element request, String response);

	/**
	 * 
	 * @return the bots response.
	 */
	public String getNewResponse();

	/**
	 * Will search through the available requests and either return one that
	 * already exists or create and attach a new one to the structure.
	 * 
	 * @param the
	 *            request to search for or create.
	 * @return the newly created element.
	 */
	public Element addRequest(String request);

	/**
	 * Saves the personality. Default is saving to a readable XML file.
	 * 
	 * @param location
	 *            at which the file is to be saved to.
	 * @param toSerialized
	 *            to a serialized file.
	 */
	public void savePersonality(File location, boolean toSerialized) throws IOException;

	public void savePersonality(String location, boolean toSerialized) throws IOException;

	/**
	 * Default loading is from a readable XML file.
	 * 
	 * @param location
	 *            at which the file is to be loaded from
	 * @param fromSerialized
	 *            from Serialized file.
	 * @return the personality Element
	 */
	public Element loadPersonality(File location, boolean fromSerialized) throws JDOMException, IOException;

	public Element loadPersonality(String location, boolean fromSerialized) throws JDOMException, IOException;

	/**
	 * Initializes a new thread for the bot to run on.
	 */
	public void exe();
}